package com.example.springcloud.order.feign;

import com.example.springcloud.order.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * 账户服务 Feign 客户端
 */
@FeignClient(value = "account-service", path = "/account")
public interface AccountServiceFeign {

    /**
     * 扣减余额 - AT 模式
     */
    @PostMapping("/deduct")
    Result<Void> deduct(@RequestParam("userId") Long userId,
                       @RequestParam("money") BigDecimal money);

    /**
     * 扣减余额 - TCC Try 阶段
     */
    @PostMapping("/deduct/tcc/try")
    Result<Void> deductTccTry(@RequestParam("userId") Long userId,
                              @RequestParam("money") BigDecimal money);

    /**
     * 扣减余额 - XA 模式
     */
    @PostMapping("/deduct/xa")
    Result<Void> deductXa(@RequestParam("userId") Long userId,
                          @RequestParam("money") BigDecimal money);
}

